//
//  DoctorInfoHeadView.m
//  kuaiyiDemo
//
//  Created by vn on 16/7/7.
//  Copyright © 2016年 vn. All rights reserved.
//

#import "DoctorInfoHeadView.h"
#import "Masonry.h"
#import "DoctorInfoController.h"
@interface DoctorInfoHeadView()

//医生头像
@property(nonatomic,strong)UIImageView * doctor_img;
//医院名称
@property(nonatomic,strong)UILabel * hospitalName_lb;
//医生职称
@property(nonatomic,strong)UILabel * doctorPosition_lb;
//医生名字
@property(nonatomic,strong)UILabel * doctorName_lb;
//评分
@property(nonatomic,strong)UIButton * btn_pf;
//鲜花
@property(nonatomic,strong)UIButton * btn_xh;
//点赞
@property(nonatomic,strong)UIButton * btn_dz;


@end
@implementation DoctorInfoHeadView

- (instancetype)init{
    
    if (self = [super init]) {
        
        
        [self setUpUI];
        
    }
    
    return self;
    
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    
    
    [self.doctor_img mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.offset(30);
        make.left.equalTo(self).offset(15);
        make.width.equalTo(@80);
        make.height.equalTo(@80);
        
    }];
    
    
    [self.doctorName_lb mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.doctor_img.mas_top).offset(10);
        make.left.mas_equalTo(self.doctor_img.mas_right).offset(10);
        
    
    }];
    
    [self.doctorPosition_lb mas_updateConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.doctorName_lb.mas_top);
        make.left.mas_equalTo(self.doctorName_lb.mas_right).offset(10);
        
        
        
    }];
    
    
    [self.hospitalName_lb mas_updateConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.doctorName_lb.mas_bottom).offset(10);
        make.leading.mas_equalTo(self.doctorName_lb.mas_leading);
        
        
    }];
    
    
    [self.btn_pf mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.doctor_img.mas_bottom).offset(20);
        make.left.mas_offset(30);
        
        
    }];
    
    
    [self.btn_xh mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.btn_pf.mas_top);
        make.centerX.equalTo(self.mas_centerX);
        
        
        
    }];
    
    [self.btn_dz mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.btn_xh.mas_top);
        make.right.mas_offset(-30);
        
        
    }];
    
    
    
}

#pragma mark -- 布局子控件
 - (void)setUpUI{
    
    [self addSubview:self.doctor_img];
    [self addSubview:self.doctorName_lb];
    [self addSubview:self.doctorPosition_lb];
    [self addSubview:self.hospitalName_lb];
    [self addSubview:self.btn_pf];
    [self addSubview:self.btn_dz];
    [self addSubview:self.btn_xh];
}


- (void)setFocusModel:(SEFocusModel *)focusModel{
    
    _focusModel = focusModel;
    
    self.doctorName_lb.text = focusModel.doctor_name;
    self.doctorPosition_lb.text = focusModel.doctor_title_name;
    self.hospitalName_lb.text = focusModel.doctor_hospital_name;
    [self.doctor_img  sd_setImageWithURL:[NSURL URLWithString:focusModel.doctor_portrait]];
    
}


#pragma mark -- lazy控件

- (UIButton *)btn_pf{
    
    if (_btn_pf == nil) {
        
        
        _btn_pf = [[UIButton alloc]init];
        [_btn_pf setTitle:@" 10" forState:UIControlStateNormal];
        [_btn_pf setImage:[UIImage imageNamed:@"yuyueliang"] forState:UIControlStateNormal];
        _btn_pf.titleLabel.font = [UIFont systemFontOfSize:14];
        [_btn_pf setTitleColor:[UIColor colorWithRed:0.2069 green:0.7387 blue:0.7914 alpha:1.0]forState:UIControlStateNormal];

    }
    
    return _btn_pf;
}

- (UIButton *)btn_xh{
    
    if (_btn_xh == nil) {
        
        
        _btn_xh = [[UIButton alloc]init];
        [_btn_xh setTitle:@" 100" forState:UIControlStateNormal];
        [_btn_xh setImage:[UIImage imageNamed:@"xianhua"] forState:UIControlStateNormal];
        _btn_xh.titleLabel.font = [UIFont systemFontOfSize:14];
        [_btn_xh setTitleColor:[UIColor colorWithRed:0.2069 green:0.7387 blue:0.7914 alpha:1.0]forState:UIControlStateNormal];
        
    }
    
    return _btn_xh;
}

- (UIButton *)btn_dz{
    
    if (_btn_dz == nil) {
        
        
        _btn_dz = [[UIButton alloc]init];
        [_btn_dz setTitle:@" 30" forState:UIControlStateNormal];
        [_btn_dz setImage:[UIImage imageNamed:@"jinqi"] forState:UIControlStateNormal];
        _btn_dz.titleLabel.font = [UIFont systemFontOfSize:14];
        [_btn_dz setTitleColor:[UIColor colorWithRed:0.2069 green:0.7387 blue:0.7914 alpha:1.0]forState:UIControlStateNormal];
        
    }
    
    return _btn_dz;
}



- (UIImageView *)doctor_img{
    
    if (_doctor_img == nil) {
        
        _doctor_img = [[UIImageView alloc]init];
        _doctor_img.image = [UIImage imageNamed:@"illness_img_person.png"];
        _doctor_img.layer.cornerRadius = 40;
        _doctor_img.layer.masksToBounds = YES;
        
        
    }
    
    return _doctor_img;
}

- (UILabel *)doctorName_lb{
    
    if (_doctorName_lb == nil) {
        
        _doctorName_lb = [[UILabel alloc]init];
    }
    
    return _doctorName_lb;
}

-  (UILabel *)doctorPosition_lb{
    
    if (_doctorPosition_lb == nil) {
        
        
        _doctorPosition_lb = [[UILabel alloc]init];
        _doctorPosition_lb.font = [UIFont systemFontOfSize:14];
        _doctorPosition_lb.textColor = [UIColor grayColor];
    }
    
    return _doctorPosition_lb;
}

- (UILabel *)hospitalName_lb{
    
    if (_hospitalName_lb == nil) {
        
       
        _hospitalName_lb = [[UILabel alloc]init];
         _hospitalName_lb.font = [UIFont systemFontOfSize:14];
         _hospitalName_lb.textColor = [UIColor grayColor];
    }
    return _hospitalName_lb;
}

@end
